﻿
namespace Apache.Cassandra.Client {
    using System;

    [CLSCompliant(false)]
    public static class ColumnOrSuperColumnExtensions {

        public static object GetItem(this ColumnOrSuperColumn column) {
            if (null == column) {
                return null;
            }

            if (null != column.Column) {
                return column.Column;
            }
            if (null != column.Super_column) {
                return column.Super_column;
            }
            return null;
        }

        public static byte[] GetName(this ColumnOrSuperColumn column) {
            if (null == column) {
                return null;
            }

            if (null != column.Column) {
                return column.Column.Name;
            }
            if (null != column.Super_column) {
                return column.Super_column.Name;
            }
            return null;
        }

        public static object GetValue(this ColumnOrSuperColumn column) {
            if (null == column) {
                return null;
            }

            if (null != column.Column) {
                return column.Column.Value;
            }
            if (null != column.Super_column) {
                return column.Super_column.Columns;
            }
            return null;
        }
    }
}
